//package com.imiku.config;
//
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.context.annotation.Bean;
//import org.springframework.context.annotation.Configuration;
//import org.springframework.security.authentication.AuthenticationManager;
//import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder;
//import org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity;
//import org.springframework.security.config.annotation.web.builders.HttpSecurity;
//import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
//import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
//import org.springframework.security.core.session.SessionRegistry;
//import org.springframework.security.core.session.SessionRegistryImpl;
//import org.springframework.security.core.userdetails.UserDetailsService;
//import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
//import org.springframework.security.crypto.password.PasswordEncoder;
//
///**
// * Created by Yuicon on 2017/5/14.
// * https://segmentfault.com/u/yuicon
// */
//@Configuration
//@EnableWebSecurity
////@EnableGlobalMethodSecurity(prePostEnabled = true)
//public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
//
//    // Spring会自动寻找实现接口的类注入,会找到我们的 UserDetailsServiceImpl  类
////    @Autowired
////    private UserDetailsService userDetailsService;
////    @Autowired
////    UrlFilterInvocationSecurityMetadataSource urlFilterInvocationSecurityMetadataSource;
////    @Autowired
////    UrlAccessDecisionManager urlAccessDecisionManager;
//
////    @Override
////    public void configure(AuthenticationManagerBuilder auth) throws Exception {
////        // 使用自定义身份验证组件
////        auth.userDetailsService(userDetailsService).passwordEncoder(passwordEncoder());
////    }
////
////    // 装载BCrypt密码编码器
//    @Bean
//    public PasswordEncoder passwordEncoder() {
//        return new BCryptPasswordEncoder();
//    }
//
//    // 设置 HTTP 验证规则
//    @Override
//    protected void configure(HttpSecurity http) throws Exception {
////        http.csrf().disable()
////                .sessionManagement()
////                .invalidSessionUrl("/session/invalid")
////                .maximumSessions(1)
////                .maxSessionsPreventsLogin(true)
////                //.expiredSessionStrategy(new MyExpiredSessionStrategy())
////                .sessionRegistry(sessionRegistry());
////
//        http
//                .requestMatchers().anyRequest()
//                .and()
//                .authorizeRequests()
//                .antMatchers("/oauth/**", "/session/invalid").permitAll();
//    }
//
//    @Bean
//    @Override
//    public AuthenticationManager authenticationManagerBean() throws Exception {
//        return super.authenticationManagerBean();
//    }
//
////    @Bean
////    public SessionRegistry sessionRegistry() {
////        return new SessionRegistryImpl();
////    }
//
//}